In [1]:
import numpy as np
import math
import matplotlib.pyplot as plt
%matplotlib inline

Neural Networks with 3 layers and (3,2,2) number of nodes


In [2]:
#Layer 1 - input
print ("Layer 1")
X1 = np.array ([[1,0,1],
               [1+0.,0,1],
               [1,1,1],
               [1,0,0]])
print ("X1 =", X1)


Layer 1
X1 = [[ 1.  0.  1.]
 [ 1.  0.  1.]
 [ 1.  1.  1.]
 [ 1.  0.  0.]]

In [3]:
# Layer 2 
print ("Layer2")
B2 = np.array ([0,0])
print ("B2 =" , B2)
print ("X1 =", X1)
W12 = np.array ([[0,1],
                [0,0],
                [1,0]])
#W1 = np.random.randn(4, 3)

W12
print ("W12 =") 
print (W12)
Y2 = X1.dot(W12) + B2
print ("Y2 =", Y2)
A2 =1/(1+np.exp(-Y2))
print ("A2 =", A2)


Layer2
B2 = [0 0]
X1 = [[ 1.  0.  1.]
 [ 1.  0.  1.]
 [ 1.  1.  1.]
 [ 1.  0.  0.]]
W12 =
[[0 1]
 [0 0]
 [1 0]]
Y2 = [[ 1.  1.]
 [ 1.  1.]
 [ 1.  1.]
 [ 0.  1.]]
A2 = [[ 0.73105858  0.73105858]
 [ 0.73105858  0.73105858]
 [ 0.73105858  0.73105858]
 [ 0.5         0.73105858]]

In [4]:
# Layer 3 
print ("Layer3")
B3 = np.array ([0,0])
print ("B2 =" , B2)
print ("A2 =", A2)
W23 = np.array ([[1,0],
                [0,1]])
#W3 = np.random.randn(2, 3)
print ("W23 =") 
print (W23)
Y3 = A2.dot(W23) + B3
print ("Y3 =", Y3)
A3 =1/(1+np.exp(-Y3))
print ("A3 =", A3)


Layer3
B2 = [0 0]
A2 = [[ 0.73105858  0.73105858]
 [ 0.73105858  0.73105858]
 [ 0.73105858  0.73105858]
 [ 0.5         0.73105858]]
W23 =
[[1 0]
 [0 1]]
Y3 = [[ 0.73105858  0.73105858]
 [ 0.73105858  0.73105858]
 [ 0.73105858  0.73105858]
 [ 0.5         0.73105858]]
A3 = [[ 0.67503753  0.67503753]
 [ 0.67503753  0.67503753]
 [ 0.67503753  0.67503753]
 [ 0.62245933  0.67503753]]

In [ ]:


In [ ]: